/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.thesis.algorithm;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;

/**
 *
 * @author Administrator
 */
public class SequenceElement {
    public char Observation; 	// observations
    public char Lac; 			//additional info
	public char State; 			// hidden states
    public char Repetition;	


    public SequenceElement()
    {
        Observation = 0;
        State=0;
        Lac = 0;
        Repetition=1;
    }
    
    public SequenceElement(SequenceElement se)
    {
        Observation = se.Observation;
        State=se.State;
        Lac = se.Lac;
        Repetition=se.Repetition;
    }
    public SequenceElement(char observation, char state)
    {
        Observation = observation;
        State=state;
        Lac = 0;
        Repetition = 1;
    }
    
    public SequenceElement(char observation, char state, char lac)
    {
        Observation = observation;
        State=state;
        Lac = lac;
        Repetition = 1;

    }
    
    public SequenceElement(char observation, char state, char lac, char repetition)
    {
        Observation = observation;
        State=state;
        Lac = lac;
        Repetition = repetition;
    }


    public String toString() {
        return "==s" + (int)State + ":o" + (int)Observation + ":l" + (int)Lac + ":r" + (int)Repetition;
       // return (int)State + "||" + (int)Observation + "  ";
    }

    public void writeBinary(DataOutputStream out) throws IOException {
        out.writeChar(this.Observation);
        out.writeChar(this.State);
        out.writeChar(this.Lac);
        out.writeChar(this.Repetition);
    }
    
    public void readBinary(DataInputStream in) throws IOException {
        this.Observation = in.readChar();
        this.State = in.readChar();
        this.Lac = in.readChar();
        this.Repetition = in.readChar();
    }
    
    public boolean isEqual(SequenceElement el) {
        if (el == null)
            return false;
        if (el.State != this.State || el.Observation != this.Observation || el.Lac != this.Lac)
            return false;
        return true;
    }
}
